package xin.printk.android.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class DateUtils {

    public static String timeStampToDate(long timestamp) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
        Date date = new Date(timestamp);
        return dateFormat.format(date);
    }

    public static long dateToTimeStamp(Date date) {
        return date.getTime();
    }

    public static long dateToTimeStamp(String time) throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
        Date date = dateFormat.parse(time);
        return date.getTime();
    }

}
